
$(function (){

    // 获取当前所有品牌
    $.ajax({
        url:"/brandManage/getBrandByConditionToProductPage2",
        type:"post",
        data:{},
        dataType: "json",
        success:function (result){
            if (result!=null){
                let str = "";
                for (let i in result){
                    str += "<option>"+result[i].brandName+"</option>";
                }
                $(".brandName").html(str);
            }
        }
    })

    // 获取当前的全部商品类型
    $.ajax({
        url:"/productType/getTypesList",
        type:"post",
        data:{},
        dataType: "json",
        success:function (result){
            if (result!=null){
                let str = "";
                for (let i in result){
                    str += "<option>"+result[i].typeName+"</option>";
                }
                $(".typeName").html(str);
            }
        }
    })

    $(".updateProductBtn").click(function (){

        // 获取修改之后的商品类型信息
        let brandName = $(".brandName").val();
        let typeName = $(".typeName").val();
        let productModel = $(".productModel").val();
        let productUnit = $(".productUnit").val();
        let productStatus = $(".productStatus").val();

        $.ajax({
            url:"/productManage/updateProduct",
            type:"post",
            data:{"brandName":brandName,"typeName":typeName,"productModel":productModel,"productUnit":productUnit,"productStatus":productStatus},
            dataType:"json",
            success:function (result){
                if (result == true){
                    alert("修改成功");
                }else {
                    alert("修改失败");
                }
            }
        })

    })


})